package com.andrewli.designpattern;

public class Singleton {
    private static Singleton sInstance = null;

    public static Singleton getInstance() {
        if(null == sInstance) {
            synchronized (Singleton.class) {
                if(null == sInstance) {
                    sInstance = new Singleton();
                }
            }
        }
        return sInstance;
    }

    public void sayHello() {
        System.out.print("Hello, world!\n");
    }

    private Singleton() {
    }

    public static void main(String[] args) {
        Singleton.getInstance().sayHello();
    }
}
